Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

537
Views
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002]

Recently I followed a tutorial for making a forum with PHP and MySQL. Then I got this error: Error: parsererror - SyntaxError: Unexpected token < in JSON at position 0
I figured out why it was saying that. There was a error on save.php and which was caused due to a error in conn.php this is the full error on conn.php : Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /home/runner/AnchoredHeftyTrigger/conn.php:6 Stack trace: #0 /home/runner/AnchoredHeftyTrigger/conn.php(6): PDO->__construct('mysql:host=loca...', 'root', '') #1 {main} thrown in /home/runner/AnchoredHeftyTrigger/conn.php on line 6
This is the code of conn.php:

<?php
session_start();
$db_username = 'root';
$db_password = '';

$conn = new PDO('mysql:host=localhost;dbname=forum', 
                $db_username, $db_password);
if(!$conn){
die("Fatal Error: Connection Failed!");
}

?>

I'm sorry if I'm not giving much information: I'm very new with PHP and JSON

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!